package net.oschina.app.pages;

import android.widget.Button;
import android.widget.EditText;

import net.oschina.app.SoloWrap;

/**
 * Created by Administrator on 2018/3/19.
 * <p>
 * 登录页面的一些常见操作，封装一些方法
 */

public class PageLogin {
    private SoloWrap solo;
    private EditText nameET, pwdET;
    private Button loginBtn;


    public PageLogin(SoloWrap solo) {
        this.solo = solo;
    }


    //获取控件的方法
    public void initViews() {
        nameET = (EditText) solo.getView("net.oschina.app:id/et_username");
        pwdET = (EditText) solo.getView("net.oschina.app:id/et_password");
        loginBtn = (Button) solo.getView("net.oschina.app:id/btn_login");
    }

    public void cleanNameEditText() {
        solo.clearEditText(nameET);
    }


    public void cleanPwdEditText() {
        solo.clearEditText(pwdET);
    }

    public void enterNameEditText(String name) {
        solo.enterText(nameET, name);
    }

    public void enterPwdEditText(String pwd) {
        solo.enterText(pwdET, pwd);
    }

    public void clickLoginBtn() {
        solo.clickOnView(loginBtn);
    }

    public void login(String name, String pwd) {
        cleanNameEditText();
        enterNameEditText(name);
        cleanPwdEditText();
        enterPwdEditText(pwd);
        clickLoginBtn();
    }


}
